import request from '@/config/axios'
import type { TransactionCode } from './types'

export const getTransactionCodesListApi = (params: any): Promise<IResponse> => {
  return request.get({ url: '/transaction-codes', params })
}

export const getGratedTransactionCodesApi = (params: any): Promise<IResponse> => {
  return request.get({ url: '/transaction-codes/granted', params })
}

export const createTransactionCodesApi = (data: Partial<TransactionCode>): Promise<IResponse> => {
  return request.post({ url: '/transaction-codes', data })
}

export const updateTransactionCodesApi = (
  id: string,
  data: Partial<TransactionCode>
): Promise<IResponse> => {
  return request.put({ url: `/transaction-codes/id/${id}`, data })
}

export const getTransactionCodesDetailApi = (id: string): Promise<IResponse<TransactionCode>> => {
  return request.get({ url: `/transaction-codes/id/${id}` })
}

export const delTransactionCodesListApi = (ids: string[] | number[]): Promise<IResponse> => {
  return request.delete({ url: `/transaction-codes/id/${ids[0]}` })
}
